package me.boot.db.mongodb;

import lombok.Getter;
import lombok.Setter;
import me.base.utils.jackson.JacksonUtil;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author :  sylar
 * @FileName :  AbstractMongoPO
 * @CreateDate :  2017/11/08
 * @Description :
 * @ReviewedBy :
 * @ReviewedOn :
 * @VersionHistory :
 * @ModifiedBy :
 * @ModifiedDate :
 * @Comments :
 * @CopyRight : COPYRIGHT(c) xxx.com All Rights Reserved
 * *******************************************************************************************
 */
@Getter
@Setter
@MappedSuperclass
@Document
public abstract class MongoEntity implements Serializable {

    @Id
    protected String id;

    @Field("create_time")
    protected LocalDateTime createTime = LocalDateTime.now();

    @Field("update_time")
    protected LocalDateTime updateTime = LocalDateTime.now();

    @Field("deleted")
    protected boolean deleted = false;

    @Override
    public String toString() {
        return JacksonUtil.toJsonString(this);
    }

}
